package com.tong.hao.batch.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;

/**
 * @ClassName ThJobListener
 * @Author 友野浩二
 * @Date 2019/11/25 22:35
 * @Description Job监听器
 * @Version 1.0
 *
 * <pre>
 *      Spring Batch 对于【任务或步骤】开始和结束都会提供监听,以便开发人员实现监听逻辑。
 * </pre>
 */
@Slf4j
public class ThJobListener extends JobExecutionListenerSupport {

    @Override
    public void beforeJob(JobExecution jobExecution) {
        log.info("Th batch job before");
        super.beforeJob(jobExecution);
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
            log.info("Th batch job complete!");
        }
    }
}
